/*
 * @Descripttion:
 * @version:
 * @Author: congsir
 * @Date: 2023-12-19 13:38:46
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2024-01-16 17:20:15
 */
import {
  createRouter,
  createWebHistory,
  createWebHashHistory,
} from "vue-router";
//  路由配置
const routes = [
  {
    path: "/",
    redirect: "/index",
  },
  {
    path: "/index",
    name: "index",
    component: () => import("../views/index.vue"),
    meta: {
      title: "index",
    },
  },
  {
    path: "/yangli",
    name: "yangli",
    component: () => import("../views/yangli.vue"),
    meta: {
      title: "yangli",
    },
  },
  {
    path: "/list",
    name: "list",
    component: () => import("../views/list.vue"),
    meta: {
      title: "list",
    },
  },
  {
    path: "/agreement",
    name: "agreement",
    component: () => import("../views/agreement.vue"),
    meta: {
      title: "agreement",
    },
  },
  {
    path: "/historyRecord",
    name: "historyRecord",
    component: () => import("../views/historyRecord.vue"),
    meta: {
      title: "historyRecord",
    },
  },
  {
    path: "/inquireOk",
    name: "inquireOk",
    component: () => import("../views/inquireOk.vue"),
    meta: {
      title: "inquireOk",
    },
  },
];

const router = createRouter({
  history: createWebHashHistory(),
  routes,
});


router.beforeEach((to, from, next) => {
  // 在每次导航之前滚动到页面顶部
  window.scrollTo({
    top: 0,
    behavior: "smooth", // 可选的，使滚动平滑进行
  });
  next();
});

// 全局解析守卫
router.beforeResolve(async (to) => {});

// 全局后置钩子
router.afterEach((to, from, failure) => {
  // if (!failure) sendToAnalytics(to.fullPath)
});

export default router;
